<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
                *{
            margin: 0;
            padding: 0;
        }
            ul{
            list-style: none;
            width: 680px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            border: 1px solid;
            box-sizing: border-box;

        }
        li{
            display: flex;
            align-items: center;
            justify-content: center;
            width: 130px;
            box-sizing: border-box;
            border: 1px solid;


        }
        .list{
            flex-direction: column;
        }
        .list li{
            width: 100%;
            height: 300px;
            display: none;
        }
    
    </style>
</head>
<body>
    <ul class="nav">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <ul class="list">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <script>
        // 获取nav中的li
        let lis = document.querySelectorAll('.nav li')
        // 获取list中的li
        let listli = document.querySelectorAll('.list li')
        for (let i = 0; i < lis.length; i++) {
            // 绑定点击事件
            lis[i].onclick=function(){
            // 去掉所有兄弟结点的样式
            for (let j = 0; j < lis.length; j++) {
                lis[j].style.background='none'                
            }
                //修改点击元素的样式
                this.style.background='red'
                // 隐藏掉所有list中的li
                for (let j = 0; j < listli.length; j++) {
                    listli[j].style.display = 'none' 
                }
                // 显示选中的li
                // nav中的li和  listli中的li是对用关系
                listli[i].style.display='flex'
            }
        }
    </script>
</body>
</html>